#define _CRT_SECURE_NO_WARNINGS
#include"sort.h"

void direct_insert_sort(array<int, 10>& arr)
{
	for (int i = 0; i < arr.size() - 1; i++)
	{
		int end = i;
		int tmp = arr[end + 1];
		while (end >= 0)
		{
			if (tmp < arr[end])
			{
				arr[end + 1] = arr[end];
				end--;
			}
			else
				break;
		}
		arr[end + 1] = tmp;
	}
}

void shell_sort(array<int, 10>& arr)
{
	int gap = 10;
	while (gap > 1)
	{
		gap /= 2;
		for (int i = 0; i < 10 - gap; i++)
		{
			int end = i;
			int temp = arr[end + gap];
			while ( end >= 0)
			{
				if (arr[end] > temp)
				{
					arr[end + gap] = arr[end];
					end -= gap;
				}
				else
					break;
			}
			arr[end + gap] = temp;
		}
	}
}

void display_date(array<int, 10>& arr)
{
	for (auto it = arr.begin(); it != arr.end(); it++)
	{
		cout << *it << " ";
	}
	cout << endl;
}